<?php use_stylesheet('main.css') ?>
<span class="heading1">Referal Income</span>
<table id="data_list">
  <tbody>
    <tr>
      <th>Username</th>
      <th>Joining Date </th>
      <th>Investment</th>
      <th>Income</th>
    </tr>
    <?php
    $total = 0;
    foreach ($data as $item):
    $total += $item->getIncome();
    $refUser = $item->getXistsUserRelatedByRefUserId();
    ?>
    <tr>
      <td><?php echo $refUser->getUsername(); ?></td>
      <td><?php echo $refUser->getJoinDate($dateFormat); ?></td>
      <td><?php echo $currency; ?> <?php echo $refUser->getDepositAmount(); ?></td>
      <td><?php echo $currency; ?> <?php echo $item->getIncome(); ?></td>
    </tr>
    <?php
    endforeach;?>
  </tbody>
  <thead>
    <tr>
      <th colspan="2">Total Referal Income:</th>
      <td colspan="2"><?php echo $currency; ?> <?php echo $total;?></td>
    </tr>
  </thead>
  <?php if (!count($data)): ?>
  <tfoot>
    <tr>
      <td colspan="4">Oops! No Transactions Found</td>
    </tr>
  </tfoot>
  <?php endif;?>
</table>